/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Xadrez.Controller;

import Xadrez.View.GameFrame;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Leonardo
 */
public class GameController {

    private GameFrame panel;

    public GameController() {

        panel = new GameFrame();
        panel.AdicionarOuvinte(new Ouvinte());
        panel.setVisible(true);


    }

    class Ouvinte implements ActionListener {

        public void actionPerformed(ActionEvent e) {
            Object fonte = e.getSource();

            if (fonte == panel.getMenuItem1()) {

                final MatchController match = new MatchController(true);
                java.awt.EventQueue.invokeLater(new Runnable() {

                    public void run() {
                        //while (true)
                        {
                         match.Paint();
                        try {
                            Thread.sleep(2000);
                        } catch (InterruptedException ex) {
                            Logger.getLogger(GameController.class.getName()).log(Level.SEVERE, null, ex);
                        }
                        }
                       
                    }
                });

            }

            if (fonte == panel.getMenuItem2()) {

                MatchController match = new MatchController(false);


            }

            if (fonte == panel.getMenuItem3()) {

                System.exit(0);


            }

        }
    }
}
